from typing import List  # noqa: D100

from ..api.db_operator import DBOperator
from ..api.git_reader import GitReader


class AccountService:
    """与 DBOperator 和 GitReader 配合，完成 Git 账号的导入工作."""

    def __init__(self, git_reader: GitReader, db_operator: DBOperator):
        self.git_reader = git_reader
        self.db_operator = db_operator

    def start_import_accounts(self):
        """启动账户导入流程."""
        accounts = []
        page = 1
        while True:
            data = self.git_reader.get_users_from_gitlab(page=page)
            if len(data) == 0:
                break
            accounts.extend(data)
            page += 1
        print(f"Fetched {len(accounts)} accounts.")
        self.db_operator.insert_accounts(accounts)

    # 其他方法根据需要
